﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StepMatchWalking : MonoBehaviour
{
    public Animator animator;
    public Vector3 moving_direction;
    public float speed = 0.1f;
    public float basic_speed = 0.06f;
    private bool is_moving = false;
    // Update is called once per frame
    private void Start()
    {
        StartCoroutine(WalkAround());
    }

    IEnumerator WalkAround()
    {
        while (true)
        {
            is_moving = true;
            animator.Play("Run");
            yield return new WaitForSeconds(3.0f);
            is_moving = false;
            transform.position = new Vector3(0, 0, 0);
        }
    }

    private void Update()
    {
        if (is_moving)
        {
            transform.Translate(moving_direction.normalized * speed);
            animator.speed = speed / basic_speed;
        }
    }

}
